# -*- coding: utf-8 -*-
# ----------------------------
# @Time    : 2025/4/3 16:27
# @Author  : acedar
# @FileName: bailian_call.py
# ----------------------------
# -*- encoding: utf-8 -*-
"""
@author: acedar
@time: 2025/1/26 16:13
@file: deepseek_text_api.py.py
"""

import os
from dotenv import load_dotenv
load_dotenv()

# Please install OpenAI SDK first: `pip3 install openai`

from openai import OpenAI

openai_api_key = os.getenv("OPENAI_API_KEY")
base_url = os.getenv("BASE_URL")  # 读取 BASE YRL
model = os.getenv("MODEL")  # 读取 model

client = OpenAI(api_key=openai_api_key, base_url=base_url)

response = client.chat.completions.create(
    model=model,
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "使用python写一个快排"},
    ],
    stream=False
)

print(response.choices[0].message.content)

json_data = response.dict()
print(type(json_data))

print(json_data["usage"]["prompt_tokens"])

